package compiler.nonterminals;

import howl.types.Alarm;
import compiler.HowlToken;
import compiler.HowlType;
import compiler.TokenReader;
import compiler.exceptions.HowlParserException;
import compiler.terminals.BooleanExpression;
import compiler.terminals.FeedName;

public class AlarmStmt extends HowlToken {

	private FeedName feedname;
	
	private BooleanExpression exp;
	
	public AlarmStmt(TokenReader tokenReader) {
		super(tokenReader);
	}

	@Override
	public String codeGenerate() {
		String str = "Alarm " + this.feedname.codeGenerate() + " " + this.exp.codeGenerate();
		return str;
	}

	@Override
	public HowlToken parse() throws HowlParserException {
		String command = this.tokenReader.consumeToken();
		if (!"alarm".equals(command))
			throw new HowlParserException(this.tokenReader.getStatement(),
					this.tokenReader.getCharNo());
		
		this.feedname = (FeedName) new FeedName(this.tokenReader).parse();
		
		String tmp = this.tokenReader.nextToken();
		if(tmp.equals("stop")) {
			
		}else{
		this.exp = (BooleanExpression) new BooleanExpression(this.tokenReader).parse();
		}
		return this;
	}

	/**
	 * @return the feedname
	 */
	public FeedName getFeedname() {
		return feedname;
	}

	/**
	 * @param feedname the feedname to set
	 */
	public void setFeedname(FeedName feedname) {
		this.feedname = feedname;
	}

	/**
	 * @return the exp
	 */
	public BooleanExpression getExp() {
		return exp;
	}

	/**
	 * @param exp the exp to set
	 */
	public void setExp(BooleanExpression exp) {
		this.exp = exp;
	}



}
